(function () {
    'use strict';
    angular.module('module.business')
        .controller('EvaluationPeopleController', EvaluationPeopleController);
    EvaluationPeopleController.$inject = ['$rootScope', '$scope', '$filter', '$uibModal', '$http', '$state', 'i18nService'];

    function EvaluationPeopleController($rootScope, $scope, $filter, $uibModal, $http, $state, i18nService) {
        var vm = $scope;
        vm.exportNum=null;
        vm.export1Num=null;
        vm.activate = activate;     //初始化
        vm.loadTable = loadTable;//加载列表
        vm.create=create;
        vm.detail=detail;
        vm.personInfo=personInfo;//测评人员信息





        vm.gridOptions = {
            multiSelect: true,                                           //多选
            enableRowSelection: true,                                  //允许选中行
            //showGridFooter:true,
            enableRowHeaderSelection: false,//允许通过点击行首选中行
            enableColumnResizing : true,//设置宽度
            enableGridMenu: true,
            enableFullRowSelection: true,                              //允许通过点击行任意位置选中行
            modifierKeysToMultiSelect: true,                           //只允许通过键盘辅助多选(前提是允许多选)
            paginationPageSize: 10,
            paginationPageSizes: [10, 20, 50]

        };
        i18nService.setCurrentLang('zh-cn');
        vm.gridOptions.onRegisterApi = onRegisterApi;
        vm.gridOptions.columnDefs = [
            {field: 'NUMBER', visible: true, name: '序号', pinnedLeft: true,cellTooltip: true,headerTooltip: true,width:'70'},
            {field: 'ORG_NO', visible: true, name: '机构编号', pinnedLeft: true,cellTooltip: true,headerTooltip: true,width:'130'},
            {field: 'ORG_NAME', visible: true, name: '机构名称', pinnedLeft: true,cellTooltip: true,headerTooltip: true},
            {field: 'ADDRESS', visible: true, name: '地址', pinnedLeft: true,cellTooltip: true,headerTooltip: true},
            {field: 'ASSESSOR_NUM', visible: true, name: '测评师总数', pinnedLeft: true,cellTooltip: true,headerTooltip: true,width:'130'},
            {field: 'UNIT_TYPE', visible: true, name: '单位类型', pinnedLeft: true,cellTooltip: true,headerTooltip: true,width:'120'},
            {field: 'QUALIFICATION', visible: true, name: '资质', pinnedLeft: true,cellTooltip: true,headerTooltip: true,width:'100'},
            {field: 'CONTACTS', visible: true, name: '单位联系人', pinnedLeft: true,cellTooltip: true,headerTooltip: true,width:'140'},
            {field: 'RECOMMAND_DATE', visible: true, name: '推荐日期', pinnedLeft: true,cellTooltip: true,headerTooltip: true,width:'140'},
            {field: 'VALIDITY_DATE', visible: true, name: '证书有效期',pinnedLeft: true,cellTooltip: true,headerTooltip: true,width:'140'}
        ];
        activate();
        return vm;

        function personInfo() {
            var  modalInstance= $uibModal.open({
                animation: true,
                ariaLabelledBy: 'modal-title',
                ariaDescribedBy: 'modal-body',
                templateUrl: 'personInfo.html',
                controller: 'PersonInfoController',
                controllerAs: 'info',
                size: 'lg'
            });
            modalInstance.result.then(function () {
            }, function () {
            });
        }

        function detail(){
            var  modalInstance= $uibModal.open({
                animation: true,
                ariaLabelledBy: 'modal-title',
                ariaDescribedBy: 'modal-body',
                templateUrl: 'detailPeople.html',
                controller: 'DetailPeopleController',
                controllerAs: 'detail',
                size: 'lg'
            });
            modalInstance.result.then(function () {
            }, function () {
            });
        }






        function create(){
            var  modalInstance= $uibModal.open({
                animation: true,
                ariaLabelledBy: 'modal-title',
                ariaDescribedBy: 'modal-body',
                templateUrl: 'createPeople.html',
                controller: 'CreatePeopleController',
                controllerAs: 'create',
                size: 'lg'
            });
            modalInstance.result.then(function () {
            }, function () {
            });
        }









        function onRegisterApi(gridApi) {
            //set gridApi on scope
            vm.gridApi = gridApi;
        }
        function activate(){
            $scope.$on('$viewContentLoaded', function () {
                App.initAjax(); // initialize core components
            });
            $rootScope.settings.layout.pageContentWhite = true;
            $rootScope.settings.layout.pageBodySolid = true;
            $rootScope.settings.layout.pageSidebarClosed = false;
            loadTable();
        }

        function loadTable(){
            $http.get('app/module/business/evaluation/people/people.json')
                .then(function(data){
                    vm.gridOptions.data = data.data.record;
                });
        }




    }
})();